function login() {
  return new Promise(((resolve, reject) => {
    wx.login({
      fail: ()=>{reject()},
      success: (res)=>{resolve(res)}
    })
  }))
}

function getUserInfo() {
  return new Promise(((resolve, reject) => {
    wx.getUserInfo({
      fail:()=>{reject()},
      success:(res => {resolve(res)})
    })
  }))
}

function chooseImage() {
  return new Promise(((resolve, reject) => {
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
      success: res => resolve(res),
      fail: () => reject()
    })
  }))
}

function showLoading(option) {
  wx.showLoading(option)
}

function hideLoading() {
  wx.hideLoading()
}

export const wxutil = {
  login,
  getUserInfo,
  showLoading,
  hideLoading,
  chooseImage
}
